<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2025/5/4
  Time: 16:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.project.DB_Order" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<!DOCTYPE html>
<html>
<head>
    <title>添加订单</title>
</head>
<body>
<h2>添加订单</h2>
<form action="addOrder.jsp" method="post">
    <label for="uid">用户ID:</label>
    <input type="text" id="uid" name="uid" required><br>
    <label for="aid">航线ID:</label>
    <input type="text" id="aid" name="aid" required><br>
    <label for="payamount">支付金额:</label>
    <input type="text" id="payamount" name="payamount" required><br>
    <input type="submit" value="添加订单">
</form>
<%
    if ("post".equalsIgnoreCase(request.getMethod())) {
        String uid = request.getParameter("uid");
        String aid = request.getParameter("aid");
        String payamount = request.getParameter("payamount");

        List<String> addInput = new ArrayList<>();
        addInput.add(uid);
        addInput.add(aid);
        addInput.add(payamount);

        DB_Order dbOrder = new DB_Order();
        boolean addResult = dbOrder.add(addInput);

        if (addResult) {
            response.sendRedirect("index.jsp");
        } else {
            out.println("添加订单失败");
        }
    }
%>
</body>
</html>